<?php
	/**
	 * Created by PhpStorm.
	 * User: Administrator
	 * Date: 2018/4/4
	 * Time: 15:45
	 */
	include "../conn.php";
	header('Content-Type:text/html;charset=UTF-8');	
	//获取管理员资料数据
	$AdministratorId=$_GET['AdministratorId'];
	$AdministratorName=urldecode($_GET['AdministratorName']);

	
	//获取学生资料数据
	$StudentId=$_GET['StudentId'];
	$StudentPassword=urldecode($_GET['StudentPassword']);
	$StudentName=urldecode($_GET['StudentName']);

	$Sex=$_GET['Sex'];
	$Class=$_GET['Class'];
	$Tel=$_GET['Tel'];
	$email=$_GET['email'];
	$QQ=$_GET['QQ'];
	$Depart=$_GET['Depart'];
	
	//获取教师资料数据
	$TeacherId=$_GET['TeacherId'];
	$TeacherPassword=$_GET['TeacherPassword'];
	$TeacherName=urldecode($_GET['TeacherName']);

	//修改的用户类型
	$usertype=$_GET['saved'];		
	
	//修改学生资料数据
	if($usertype=='s-change'){
	    $sql="update student set StudentId='$StudentId',StudentName='$StudentName',Sex='$Sex',
	          Tel='$Tel',Class='$Class',email='$email',QQ='$QQ',Major='$Depart'
	           where StudentId='$StudentId'";
	    
	    if(mysqli_query($conn,$sql)){
	        echo("修改成功");
	    }
	    else {
	    	echo("修改失败");
	    }
	}
	
	//修改教师资料数据
	if($usertype=='t-change'){
		$sql="update teacher set TeacherId='$TeacherId',TeacherName='$TeacherName',
			  Sex='$Sex',Tel='$Tel',QQ='$QQ',Depart='$Depart',email='$email'
		      where TeacherId='$TeacherId'";
		 
		if(mysqli_query($conn,$sql)){
			echo("修改成功");
		}
		else {
            echo $sql.error_get_last();
			echo("修改失败");
		}
	}


?>
